<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/* Start of file bank.php */
/* Location: ./cashflow/controllers/bank.php */
class Bank extends CI_Controller {
	
	function __construct(){
		parent::__construct();
		$this->load->model('accounts'); /** load table Rekening **/ 
        $this->load->model('banks'); /** load model bank **/ 
        if(!$this->session->userdata('username')) /** restrict area if not acces to login page**/
			redirect('/',301); 
    }
    
    function summary(){
        $this->ws->set('title',lang('summary_bank'));/** title page */
		$this->ws->set('username',$this->session->userdata('username')); /** username session */
		$this->ws->set('department',$this->session->userdata('dep')); /** departement session */
        if($this->session->userdata('acc_month')):
            $month  =   $this->session->userdata('acc_month');
            $year   =   $this->session->userdata('acc_year');
        else:
            $month  =   '-';
            $year   =   '-';
        endif;
        $this->ws->set('month',$month); /** variabel month **/
        $this->ws->set('year',$year); /** variabel year **/   
        $this->ws->set('accounts',$this->accounts->getAllAccount()); /** Get Data Table Rekening */
        $this->ws->set('kurs',$this->accounts->getConvertSaldo('USD',$month,$year)); /** Get Data Table Convertion USD to IDR*/
        $this->ws->set_theme('smooth'); /** set theme to smooth **/
		$this->ws->view('bank/index_summary'); /** view layout to views/bank/index_summary*/
    }
    
    function getSummaryBank(){
        $value  = array('acc_month'=>$this->input->post('month'),'acc_year'=>$this->input->post('year')); /** value **/
        $this->session->set_userdata($value); /** set userdata value **/
        redirect('cashflow/bank/summary',301); /** redirect to summary **/
    }
    
    function getSummaryBankExport(){  
        /** if export via excel **/    
		if($this->input->post('export')=='excel')
            redirect('cashflow/bank/getSummaryBankExcel/'); 
        /** if export via pdf **/    
        elseif($this->input->post('export')=='pdf')    
            redirect('cashflow/bank/getSummaryBankPdf/');
        /** if export via email **/  
        elseif($this->input->post('export')=='email')    
            redirect('cashflow/bank/getSummaryBankEmail');
		else
			echo 'Error redirecting'; /** if error redirecting the page **/
    }
    
    function getSummaryBankEmail($month,$year,$provider){
       /** Session Variabel **/
        $month  =   $this->session->userdata('acc_month');
        $year   =   $this->session->userdata('acc_year'); 
        $excel  =   $this->banks->getExcelSummary($month,$year); /** file */
           
        /** email configuration **/
        $mail_config    =   $this->config->item('mail');
        $smtp_host      =   $mail_config['smtp_host'];
        $smtp_port      =   $mail_config['smtp_port'];
        $from_mail      =   $mail_config['from_mail'];
        $from_name      =   $mail_config['from_name'];
        
        /** php ini set email **/
        ini_set("SMTP",$smtp_host);
        ini_set("smtp_port",$smtp_port);
        ini_set('sendmail_from',$from_mail);
        /** Properties of export **/
        $subject        = 'BBG SAF Summary Bank Bulan'.month_name($month)."  Tahun". $year;
        $contents       = 'Dilampirkan Summary Bank Bulan'.month_name($month)."  Tahun". $year;
        $this->email->initialize($mail_config);
        $this->email->from($from_mail,$from_name);
        $email  =   'hendarsyahss@gmail.com';
        $this->email->to($email); /** email to */
        $this->email->subject($subject); /** email subject */
        $this->email->message($contents); /** email content */
        $this->email->attach($excel);  /** email attachement */
        $d=$this->email->send(); /** email send */
        if(!$d):
            $this->session->set_flashdata('error','error');
        else:
			$this->session->set_flashdata('success','success');
        endif;
        redirect('cashflow/bank/summary',301);
    }
    
    function getSummaryBankExcel(){
        /** Session Variabel **/
        $month  =   $this->session->userdata('acc_month');
        $year   =   $this->session->userdata('acc_year'); 
       	$excel  =   $this->banks->getExcelSummary($month,$year); /** file */
        $value  =   file_get_contents($excel); /** Read the file's contents **/
        $name   =   'Bank_saldo-Summary.xls'; /** file name content **/
        force_download($name,$value); /** download the file **/
    }
    
    function getSummaryBankPdf(){
        /** Session Variabel **/
        $month  =   $this->session->userdata('acc_month');
        $year   =   $this->session->userdata('acc_year');
        $this->ws->set('month',$month); /** variabel month **/
        $this->ws->set('year',$year); /** variabel year **/   
        $this->ws->set('accounts',$this->accounts->getAllAccount()); /** Get Data Table Rekening */
        $this->ws->set('kurs',$this->accounts->getConvertSaldo('USD',$month,$year)); /** Get Data Table Convertion USD to IDR*/
        $this->ws->set_theme('smooth-report'); /** set theme to smooth report **/
		$data = $this->ws->view('bank/pdf_summary','',TRUE); /** view layout to views/bank/pdf bank Summary **/
        pdf_create($data,'bank-saldo'); /** Create a pdf Document **/
    }
    
    function getSummaryBankReset(){
        $value  = array('acc_month'=>'acc_month','acc_year'=>'acc_year'); /** value **/
        $this->session->unset_userdata($value); /** set userdata value **/
        redirect('cashflow/bank/summary',301); /** redirect to summary **/
    }
    
    function details(){
        $this->ws->set('title',lang('details_bank'));/** title page */
		$this->ws->set('username',$this->session->userdata('username')); /** username session */
		$this->ws->set('department',$this->session->userdata('dep')); /** departement session */
        if($this->session->userdata('acc2_month')):
            $month  =   $this->session->userdata('acc2_month');
            $year   =   $this->session->userdata('acc2_year');
            $acc    =   $this->session->userdata('acc2_account');
        else:
            $month  =   '-';
            $year   =   '-';
            $acc    =   '-';
        endif;
        $this->ws->set('month',$month); /** variabel month **/
        $this->ws->set('year',$year); /** variabel year **/ 
        $this->ws->set('account',$acc); /** variabel account **/  
        $this->ws->set('accounts',$this->accounts->getAccountData()); /** Get Data Table Rekening */
        $this->ws->set('bankbooks',$this->banks->getSQLBankBook($month,$year,$acc)); /** Get Data Table Rekening */
        $this->ws->set('saldo',$this->accounts->getAccountSaldo($acc,$month,$year,'yes')); /** Get Data Table Convertion USD to IDR*/
        $this->ws->set_theme('smooth'); /** set theme to smooth **/
		$this->ws->view('bank/index_details'); /** view layout to views/bank/index_details */
    }
    
    function getDetailBank(){
        $value  = array('acc2_month'=>$this->input->post('month'),'acc2_year'=>$this->input->post('year'),'acc2_account'=>$this->input->post('account')); /** value **/
        $this->session->set_userdata($value); /** set userdata value **/
        redirect('cashflow/bank/details',301); /** redirect to details **/
    }
    
    function getDetailBankExport(){  
        /** if export via excel **/    
		if($this->input->post('export')=='excel')
            redirect('cashflow/bank/getDetailBankExcel/'); 
        /** if export via pdf **/    
        elseif($this->input->post('export')=='pdf')    
            redirect('cashflow/bank/getDetailBankPdf/');
        /** if export via email **/  
        elseif($this->input->post('export')=='email')    
            redirect('cashflow/bank/getDetailBankEmail');
		else
			echo 'Error redirecting'; /** if error redirecting the page **/
    }
    
    function getDetailBankEmail(){
       /** Session Variabel **/
        $month  =   $this->session->userdata('acc2_month');
        $year   =   $this->session->userdata('acc2_year'); 
        $acc    =   $this->session->userdata('acc2_account'); 
        $excel  =   $this->banks->getExcelDetails($month,$year,$acc); /** file */
           
        /** email configuration **/
        $mail_config    =   $this->config->item('mail');
        $smtp_host      =   $mail_config['smtp_host'];
        $smtp_port      =   $mail_config['smtp_port'];
        $from_mail      =   $mail_config['from_mail'];
        $from_name      =   $mail_config['from_name'];
        
        /** php ini set email **/
        ini_set("SMTP",$smtp_host);
        ini_set("smtp_port",$smtp_port);
        ini_set('sendmail_from',$from_mail);
        /** Properties of export **/
        $subject        = 'BBG SAF Detail Buku Bank Bulan'.month_name($month)."  Tahun". $year;
        $contents       = 'Dilampirkan Detail Bank Bulan'.month_name($month)."  Tahun". $year;
        $this->email->initialize($mail_config);
        $this->email->from($from_mail,$from_name);
        $email  =   'hendarsyahss@gmail.com';
        $this->email->to($email); /** email to */
        $this->email->subject($subject); /** email subject */
        $this->email->message($contents); /** email content */
        $this->email->attach($excel);  /** email attachement */
        $d=$this->email->send(); /** email send */
        if(!$d):
            $this->session->set_flashdata('error','error');
        else:
			$this->session->set_flashdata('success','success');
        endif;
        redirect('cashflow/bank/details',301);
    }
    
    function getDetailBankExcel(){
        /** Session Variabel **/
        $month  =   $this->session->userdata('acc2_month');
        $year   =   $this->session->userdata('acc2_year'); 
        $acc    =   $this->session->userdata('acc2_account'); 
       	$excel  =   $this->banks->getExcelDetails($month,$year,$acc); /** file */
        $value  =   file_get_contents($excel); /** Read the file's contents **/
        $name   =   'Buku-Bank_Details.xlsx'; /** file name content **/
        force_download($name,$value); /** download the file **/
    }
    
    function getDetailBankPdf(){
        /** session variabel **/
        $month  =   $this->session->userdata('acc2_month');
        $year   =   $this->session->userdata('acc2_year'); 
        $account=   $this->session->userdata('acc2_account');
         
        $acc    = $this->accounts->getAccount($account);
        $branch = $acc['Branch'];
        $name   = $acc['NoRekening'].'('. $acc['MataUang'].')';
        
        $saldo  = $this->accounts->getAccountSaldo($account,$month,$year,'yes'); 
        $bankbooks = $this->banks->getSQLBankBook($month,$year,$account);  
        
        $pdf = tcpdf();
        $pdf->setPageOrientation ('L', '', 8); 
        $pdf->setPrintHeader(false);
        $pdf->setPrintFooter(false);
        $k=0;
        $pdf->AddPage();
        /** initialization of x & y axis **/
        $x_axis_initial = 7;
        $y_axis_initial = 7;
        $x_axis = $x_axis_initial;
        $y_axis = $y_axis_initial;
        
        $pdf->SetFont('helvetica', '', 8);
        $pdf->SetFillColor(255, 255, 255);
        $pdf->SetTextColor(0, 0, 0);
        $pdf->SetDrawColor(0, 0, 0);
        $pdf->SetLineWidth(0.3);
        
        $y_axis0=$y_axis+7; 
        $y_axis=$y_axis; 
        $pdf->SetY($y_axis0);
        $pdf->SetX($x_axis_initial); 	
        $pdf->SetY($y_axis);
        $pdf->SetX($x_axis_initial+4);
        $pdf->Cell(275, 4, 'Buku Bank Detail ', 0, 0, 'C', 1); 
        
        $y_axis=$y_axis+4;
        $pdf->SetY($y_axis);
        $pdf->SetX($x_axis_initial+4);
        $pdf->Cell(275, 4, $branch, 0, 0, 'C', 1); 
        
        $y_axis=$y_axis+4;
        $pdf->SetY($y_axis);
        $pdf->SetX($x_axis_initial+4);
        $pdf->Cell(275, 4, $name, 0, 0, 'C',1); 
        
        $y_axis=$y_axis+4; 
        $pdf->SetY($y_axis); $pdf->SetX($x_axis_initial+4);
        $pdf->Cell(275, 4, 'PT. Bayu Buana Gemilang', 0, 0, 'C', 1); 

        $y_axis=$y_axis+4; 
        $pdf->SetY($y_axis); $pdf->SetX($x_axis_initial+4);
        $pdf->Cell(275, 4, 'Periode '.month_name($month).' Tahun '.$year, 0, 0, 'C', 1);
        
        $y_axis=$y_axis+3;
        $pdf->SetFillColor(205, 201, 201);
        $pdf->SetFont('helvetica', 'B', 7); 
        
        $y_axis=$y_axis+3;
        $pdf->SetY($y_axis); $pdf->SetX($x_axis_initial); 	
        $pdf->Cell(7, 6,lang('no'), 1, 1, 'C', 1, '', 0, false, 'T', 'C');
        
        $x_axis=$x_axis+7;
        $pdf->SetY($y_axis);
        $pdf->SetX($x_axis); 	
        $pdf->Cell(17, 6, lang('date'), 1, 1, 'C', 1, '', 0, false, 'T', 'C');
        
        $x_axis=$x_axis+17;
        $pdf->SetY($y_axis);
        $pdf->SetX($x_axis); 	
        $pdf->Cell(21, 6,lang('bm_no'), 1, 1, 'C', 1, '', 0, false, 'T', 'C');
        
        $x_axis=$x_axis+21;
        $pdf->SetY($y_axis);
        $pdf->SetX($x_axis); 	
        $pdf->Cell(21, 6, lang('bk_no'), 1, 1, 'C', 1, '', 0, false, 'T', 'C');
        
        $x_axis=$x_axis+21;
        $pdf->SetY($y_axis);
        $pdf->SetX($x_axis); 	
        $pdf->Cell(74, 6,lang('information'), 1, 1, 'C', 1, '', 0, false, 'T', 'C');
        
        $x_axis=$x_axis+74; $pdf->SetY($y_axis);
        $pdf->SetX($x_axis); 	
        $pdf->Cell(22, 6,lang('cheque_no'), 1, 1, 'C', 1, '', 0, false, 'T', 'C');
        
        $x_axis=$x_axis+22;
        $pdf->SetY($y_axis);
        $pdf->SetX($x_axis); 	
        $pdf->Cell(22, 6,lang('pic'), 1, 1, 'C', 1, '', 0, false, 'T', 'C');
        
        $x_axis=$x_axis+22;
        $pdf->SetY($y_axis);
        $pdf->SetX($x_axis); 	
        $pdf->Cell(15, 6,lang('dept'), 1, 1, 'C', 1, '', 0, false, 'T', 'C');
        
        $x_axis=$x_axis+15;
        $pdf->SetY($y_axis);
        $pdf->SetX($x_axis); 	
        $pdf->Cell(20, 6, lang('detail_credit'), 1, 1, 'C', 1, '', 0, false, 'T', 'C');
        
        $x_axis=$x_axis+20;
        $pdf->SetY($y_axis);
        $pdf->SetX($x_axis); 	
        $pdf->Cell(21, 6, lang('debet'), 1, 1, 'C', 1, '', 0, false, 'T', 'C');
        
        $x_axis=$x_axis+21;
        $pdf->SetY($y_axis);
        $pdf->SetX($x_axis); 	
        $pdf->Cell(21, 6,lang('credit'), 1, 1, 'C', 1, '', 0, false, 'T', 'C');
        
        $x_axis=$x_axis+21;
        $pdf->SetY($y_axis);
        $pdf->SetX($x_axis); 	
        $pdf->Cell(21, 6, lang('saldo'), 1, 1, 'C', 1, '', 0, false, 'T', 'C');
        
        $y_axis=$y_axis+6;
        $pdf->SetFillColor(255, 255, 255);
        $pdf->SetFont('helvetica', '', 6);
        
        $i=1;
        $row = 0; 
        $balance = $saldo['Saldo'];
        $total_credit = 0;
        $total_debet  = 0;
        $saldo   = $balance;
        foreach($bankbooks as $bank):
            if($bank['NomorCek']!=""):
                $sql_sum  = $this->banks->getTotalBankBook($account,$month,$year,$bank['NomorCek']);
                $sql_data = $this->banks->sqlBankBook($month,$year,$account,'no',$bank['NomorCek']);
                $number   = $bank['NomorCek'];
                                    
            elseif($bank['NomorGiro']!=""):
                $sql_sum  = $this->banks->getTotalBankBook($account,$month,$year,'',$bank['NomorGiro']);
                $sql_data = $this->banks->sqlBankBook($month,$year,$account,'no','',$bank['NomorGiro']);
                $number   = $bank['NomorGiro'];
                                    
            elseif($bank['NomorSurat']!=""):
                $sql_sum  = $this->banks->getTotalBankBook($account,$month,$year,'','',$bank['NomorSurat']);
                $sql_data = $this->banks->sqlBankBook($month,$year,$account,'no','','',$bank['NomorSurat']);
                $number   = $bank['NomorSurat']; 
                                    
            elseif($bank['NomorBM']!=""):
                $sql_sum  = $this->banks->getTotalBankBook($account,$month,$year,'','','',$bank['NomorBM']);
                $sql_data = $this->banks->sqlBankBook($month,$year,$account,'no','','','',$bank['NomorBM']);
                $number   = "";
                                    
            elseif($bank['NomorBK']!=""):
                $sql_sum  = $this->banks->getTotalBankBook($account,$month,$year,'','','','',$bank['NomorBK']);
                $sql_data = $this->banks->sqlBankBook($month,$year,$account,'','','','','',$bank['NomorBK']);
                $number   = "";             
            endif;
            
            $value       = $sql_data->result_array();
            $credit      = $sql_sum['total_credit'];  
            $debet       = $sql_sum['total_debet'];  
            $total_data  = $sql_sum['total_data']; 
            $total_credit= $total_credit + $credit; 
            $total_debet = $total_debet + $debet; 
            
            $j=1;
            foreach($value as $val):
                if($j==1)
                    $no = $number;
                else
                    $no = ""; 
                                       
                if($j==$total_data):
                    $pay   = decimal($credit,2);					
                    $saldo = ($saldo + $val['Debet']) - $credit;						
                else:
                    $pay   = "";					 
                    $saldo = ($saldo + $val['Debet']);
                endif;
                
				/*
                $data0=strlen($val['Uraian']);
                $data2=strlen($val['PIC']);
				
				if($data0 > $data2){
					$data=$data0;
				}else{
					$data=$data2;
				}
				if($data > 0){
					//$j_tam=$data+1;
					//$row_height=3*$j_tam;	
                    $row_height=4.5 * 2;			 			
				}else{
					$row_height=4;				 
				} */
                
                if($row==0):
					$row_height=4;
					$pdf->SetY($y_axis); $pdf->SetX($x_axis_initial); 	
					$pdf->MultiCell(7,  $row_height, '', 1, 'C', 0, 0, '', '', true);
					$pdf->MultiCell(17, $row_height, ''.'   ', 1, 'L', 0, 0, '', '', true); 
					$pdf->MultiCell(21, $row_height, '', 1, 'L', 0, 0, '', '', true); 
					$pdf->MultiCell(21, $row_height, '', 1, 'L', 0, 0, '', '', true); 
					$pdf->MultiCell(74, $row_height, '', 1, 'L', 0, 0, '', '', true); 
					$pdf->MultiCell(22, $row_height, '', 1, 'C', 0, 0, '', '', true); 
					$pdf->MultiCell(22, $row_height, '', 1, 'R', 0, 0, '', '', true); 
					$pdf->MultiCell(15, $row_height, '', 1, 'R', 0, 0, '', '', true); 
					$pdf->MultiCell(20, $row_height, '', 1, 'L', 0, 0, '', '', true); 
					$pdf->MultiCell(21, $row_height, '', 1, 'L', 0, 0, '', '', true); 
					$pdf->MultiCell(21, $row_height, '', 1, 'L', 0, 0, '', '', true); 
					$pdf->MultiCell(21, $row_height,decimal($balance,2), 1, 'R', 0, 0, '', '', true); 
					$y_axis=$y_axis+$row_height;
					$row++;	
				endif;
				
				$xj = strlen($val['Uraian']);
				
				if($xj>=70):
					$row_height = 4*2;
				else:
					$row_height = 4;
				endif;	
    
                $pdf->SetY($y_axis);
				$pdf->SetX($x_axis_initial); 	
				$pdf->MultiCell(7, $row_height,$i, 1, 'C', 0, 0, '', '', true);
				$pdf->MultiCell(17, $row_height, indonesian_date($bank['Tanggal']).'   ', 1, 'L', 0, 0, '', '', true); 
				$pdf->MultiCell(21, $row_height, $val['NomorBM'], 1, 'L', 0, 0, '', '', true); 
				$pdf->MultiCell(21, $row_height, $val['NomorBK'], 1, 'L', 0, 0, '', '', true); 
				$pdf->MultiCell(74, $row_height, $val['Uraian'], 1, 'L', 0, 0, '', '', true); 
				$pdf->MultiCell(22, $row_height, $no, 1, 'C', 0, 0, '', '', true); 
				$pdf->MultiCell(22, $row_height, $val['PIC'], 1, 'L', 0, 0, '', '', true); 
				$pdf->MultiCell(15, $row_height, $val['DeptId'], 1, 'C', 0, 0, '', '', true); 
				$pdf->MultiCell(20, $row_height, number_format($val['Credit'],2,'.',','), 1, 'R', 0, 0, '', '', true); 
				$pdf->MultiCell(21, $row_height, number_format($val['Debet'],2,'.',','), 1, 'R', 0, 0, '', '', true); 
				$pdf->MultiCell(21, $row_height, $pay, 1, 'R', 0, 0, '', '', true); 
				$pdf->MultiCell(21, $row_height, number_format($saldo,2,'.',','), 1, 'R', 0, 0, '', '', true); 
				$y_axis=$y_axis+$row_height;
				$j++; $i++; 
                
                $this_y=$pdf->getY();
                if($this_y >= 190):
					 $pdf->AddPage(); 
					/** initialization of x & y axis **/
					$x_axis_initial = 7;
					$y_axis_initial = 7;
					$x_axis = $x_axis_initial;
					$y_axis = $y_axis_initial; 
					
					$pdf->SetFillColor(205, 201, 201);
					$pdf->SetFont('helvetica', 'B', 7); 
                    
					$y_axis=$y_axis+3;
                    $pdf->SetY($y_axis);
                    $pdf->SetX($x_axis_initial); 	
					$pdf->Cell(7, 6, 'No', 1, 1, 'C', 1, '', 0, false, 'T', 'C');
                    
					$x_axis=$x_axis+7; $pdf->SetY($y_axis); $pdf->SetX($x_axis); 	
					$pdf->Cell(17, 6, 'Tanggal', 1, 1, 'C', 1, '', 0, false, 'T', 'C');
					$x_axis=$x_axis+17; 
                    $pdf->SetY($y_axis); 
                    $pdf->SetX($x_axis); 	
					$pdf->Cell(21, 6, 'NO BM', 1, 1, 'C', 1, '', 0, false, 'T', 'C');
						$x_axis=$x_axis+21; $pdf->SetY($y_axis); $pdf->SetX($x_axis); 	
					$pdf->Cell(21, 6, 'NO BK', 1, 1, 'C', 1, '', 0, false, 'T', 'C');
						$x_axis=$x_axis+21; $pdf->SetY($y_axis); $pdf->SetX($x_axis); 	
					$pdf->Cell(74, 6, 'URAIAN', 1, 1, 'C', 1, '', 0, false, 'T', 'C');
						$x_axis=$x_axis+74; $pdf->SetY($y_axis); $pdf->SetX($x_axis); 	
					$pdf->Cell(22, 6, 'NO CEK/BG', 1, 1, 'C', 1, '', 0, false, 'T', 'C');
						$x_axis=$x_axis+22; $pdf->SetY($y_axis); $pdf->SetX($x_axis); 	
					$pdf->Cell(22, 6, 'PIC', 1, 1, 'C', 1, '', 0, false, 'T', 'C');
						$x_axis=$x_axis+22; $pdf->SetY($y_axis); $pdf->SetX($x_axis); 	
					$pdf->Cell(15, 6, 'DEPT', 1, 1, 'C', 1, '', 0, false, 'T', 'C');
						$x_axis=$x_axis+15; $pdf->SetY($y_axis); $pdf->SetX($x_axis); 	
					$pdf->Cell(20, 6, 'DETAIL KREDIT', 1, 1, 'C', 1, '', 0, false, 'T', 'C');
						$x_axis=$x_axis+20; $pdf->SetY($y_axis); $pdf->SetX($x_axis); 	
					$pdf->Cell(21, 6, 'DEBET', 1, 1, 'C', 1, '', 0, false, 'T', 'C');
						$x_axis=$x_axis+21; $pdf->SetY($y_axis); $pdf->SetX($x_axis); 	
					$pdf->Cell(21, 6, 'KREDIT', 1, 1, 'C', 1, '', 0, false, 'T', 'C');
						$x_axis=$x_axis+21; $pdf->SetY($y_axis); $pdf->SetX($x_axis); 	
					$pdf->Cell(21, 6, 'SALDO', 1, 1, 'C', 1, '', 0, false, 'T', 'C');
					$pdf->SetFillColor(255, 255, 255);
					$pdf->SetFont('helvetica', '', 6);
					$y_axis = $y_axis+6; 
				endif;
            endforeach;
        endforeach;
        $pdf->SetFont('helvetica', 'B', 6);
     	$pdf->SetY($y_axis); $pdf->SetX($x_axis_initial); 	
    	$pdf->MultiCell(199, 4, 'Total No Rekening : '.$account, 1, 'C', 0, 0, '', '', true);
    	$pdf->MultiCell(20, 4, number_format($balance,2,'.',','), 1, 'R', 0, 0, '', '', true); 
    	$pdf->MultiCell(21, 4, number_format($total_credit,2,'.',','), 1, 'R', 0, 0, '', '', true); 
    	$pdf->MultiCell(21, 4, number_format($total_debet,2,'.',','), 1, 'R', 0, 0, '', '', true); 
    	$pdf->MultiCell(21, 4, number_format($saldo,2,'.',','), 1, 'R', 0, 0, '', '', true); 
        $pdf->Output("Buku-Bank-Detail.pdf","I");  
        
    }
    
    function getDetailBankReset(){
        $value  = array('acc2_month'=>'acc2_month','acc2_year'=>'acc2_year','acc2_account'=>'acc2_account'); /** value **/
        $this->session->unset_userdata($value); /** set userdata value **/
        redirect('cashflow/bank/details',301); /** redirect to summary **/
    }
}